package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import cn.xfdzx.android.apps.shop.R;

/**
 * @author gzk
 * @date 2020/3/28 0028
 * description：如遇缺货
 */
public class SelectOutStockLVAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<String> mList;


    private TextView tv_select_out_stock;
    private ImageView iv_select_out_stock_dui;

    private int now_position=0;

    public SelectOutStockLVAdapter(Context mContext, ArrayList<String> mList) {
        this.mContext = mContext;
        this.mList = mList;

    }

    public void setNowPosition(int k){
        now_position=k;
        notifyDataSetChanged();
    }
    private void addData() {
        mList.add("其它商品继续配送(缺货商品退款）");
        mList.add("缺货时电话与我沟通");
        mList.add("有缺货直接取消订单");

    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        view = View.inflate(mContext, R.layout.item_select_out_stock, null);
        tv_select_out_stock = view.findViewById(R.id.tv_select_out_stock);
        iv_select_out_stock_dui = view.findViewById(R.id.iv_select_out_stock_dui);

        tv_select_out_stock.setText(mList.get(i));

        if (i == now_position) {
            tv_select_out_stock.setTextColor(mContext.getResources().getColor(R.color.color_02C557));
            iv_select_out_stock_dui.setVisibility(View.VISIBLE);
        }else {
            tv_select_out_stock.setTextColor(mContext.getResources().getColor(R.color.color_333333));
            iv_select_out_stock_dui.setVisibility(View.GONE);
        }

        return view;
    }
}
